package com.ljh.jxc.modules.suo.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ljh.jxc.modules.suo.entity.Supply;
import com.ljh.jxc.service.SupplyService;
import com.ljh.jxc.common.utils.PageUtils;
import com.ljh.jxc.common.utils.R;



/**
 * 供应商资料表
 *
 * @author liujinghui
 * @email liujinghui@163.com
 * @date 2021-12-01 13:49:03
 */
@RestController
@RequestMapping("jxc/supply")
public class SupplyController {
    @Autowired
    private SupplyService supplyService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("jxc:supply:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = supplyService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{supplyId}")
    @RequiresPermissions("jxc:supply:info")
    public R info(@PathVariable("supplyId") String supplyId){
		Supply supply = supplyService.getById(supplyId);

        return R.ok().put("supply", supply);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("jxc:supply:save")
    public R save(@RequestBody Supply supply){
		supplyService.save(supply);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("jxc:supply:update")
    public R update(@RequestBody Supply supply){
		supplyService.updateById(supply);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("jxc:supply:delete")
    public R delete(@RequestBody String[] supplyIds){
		supplyService.removeByIds(Arrays.asList(supplyIds));

        return R.ok();
    }

}
